package com.moyq5.mvc.maker.test.bean.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

/**
 * 基站记录
 * @author Moyq5
 * @date 2018年8月24日
 */
@Entity
@Table(name = "iot_lbs")
@DynamicUpdate
public class IotLbs implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 基站信息ID
	 */
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")@GenericGenerator(name = "native", strategy = "native")
    @Column(name = "lbs_id")
	private Long lbsId;
	/**
     * 序列号
     */
    @Column(name = "lbs_no", nullable = false, length = 32)
    private String lbsNo;
	/**
	 * 设备
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "device_id")
	private IotDevice device;
	/**
	 * 告警
	 */
	@ManyToOne(fetch = FetchType.LAZY, optional = true)
	@JoinColumn(name = "alarm_id")
	private IotAlarm alarm;
	/**
     * 基站TA
     */
    @Column(name = "ta", nullable = false, precision = 3, scale = 0)
    private Integer ta;
    /**
     * 基站MCC
     */
    @Column(name = "mcc", nullable = false, precision = 5, scale = 0)
    private Integer mcc;
    /**
     * 基站MNC
     */
    @Column(name = "mnc", nullable = false, precision = 3, scale = 0)
    private Integer mnc;
    /**
     * 基站LAC
     */
    @Column(name = "lac", nullable = false, precision = 5, scale = 0)
    private Integer lac;
    /**
     * 基站CI
     */
    @Column(name = "ci", nullable = false, precision = 8, scale = 0)
    private Integer ci;
    /**
     * 基站RSSI
     */
    @Column(name = "rssi", nullable = false, precision = 3, scale = 0)
    private Integer rssi;
    /**
	 * 基站定位时间
	 */
	@Column(name = "lbs_time", nullable = false, columnDefinition="datetime")
	private Date lbsTime;
	/**
	 * 添加时间
	 */
	@Column(name = "add_time", nullable = false, columnDefinition="datetime")
	private Date addTime;
	
	@PrePersist
	public void prePersist() {
		if (null == addTime) {
			addTime = new Date();
		}
	}

	public Long getLbsId() {
		return lbsId;
	}

	public void setLbsId(Long lbsId) {
		this.lbsId = lbsId;
	}

	public String getLbsNo() {
		return lbsNo;
	}

	public void setLbsNo(String lbsNo) {
		this.lbsNo = lbsNo;
	}

	public IotDevice getDevice() {
		return device;
	}

	public void setDevice(IotDevice device) {
		this.device = device;
	}

	public Integer getTa() {
		return ta;
	}

	public void setTa(Integer ta) {
		this.ta = ta;
	}

	public Integer getMcc() {
		return mcc;
	}

	public void setMcc(Integer mcc) {
		this.mcc = mcc;
	}

	public Integer getMnc() {
		return mnc;
	}

	public void setMnc(Integer mnc) {
		this.mnc = mnc;
	}

	public Integer getLac() {
		return lac;
	}

	public void setLac(Integer lac) {
		this.lac = lac;
	}

	public Integer getCi() {
		return ci;
	}

	public void setCi(Integer ci) {
		this.ci = ci;
	}

	public Integer getRssi() {
		return rssi;
	}

	public void setRssi(Integer rssi) {
		this.rssi = rssi;
	}

	public Date getLbsTime() {
		return lbsTime;
	}

	public void setLbsTime(Date lbsTime) {
		this.lbsTime = lbsTime;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	public IotAlarm getAlarm() {
		return alarm;
	}

	public void setAlarm(IotAlarm alarm) {
		this.alarm = alarm;
	}
	
}
